import { defineStore } from 'pinia';
import { ref, reactive } from 'vue';

export const modal = defineStore(
	'modal',
	() => {
		let auth = ref('');
		let share = ref(false);
		let menu = ref(false);
		let advHistory = ref([]);
		let lastTimer = reactive({
			smsLogin: 0,
			smsRegister: 0,
			changeMobile: 0,
			resetPassword: 0,
		});

		return { share, auth, menu, advHistory, lastTimer };
	},
	{
		persist: {
			enabled: true, // 这个配置代表存储生效,而且是整个store都存储,默认情况下整个状态将存储在 sessionStorage 中
			strategies: [
				{
					key: 'modal-store',
					paths: ['lastTimer', 'advHistory'],
				},
			],
		},
	},
);
